
<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        :permission="permissionList"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
      >
        <template slot="menuLeft">
          <el-button type="primary" size="small" @click="confirmBatch">确认</el-button>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import {
  confirm
} from "@/api/subwaystm/swstcyclenotice";
import { tableOption } from "@/const/crud/subwaystm/swstcyclenotice";
import baseCrud from '@/mixins/base-crud'

export default {
  name: "swstcyclenotice",
  mixins: [baseCrud('subwaystm/swstcyclenotice')],
  data() {
    return {
    };
  },
  computed: {
    permissionList() {
      return {
        addBtn: this.vaildData(this.permissions.stm_swstcycle_add, false),
        delBtn: this.vaildData(this.permissions.stm_swstcycle_del, false),
        editBtn: this.vaildData(this.permissions.stm_swstcycle_edit, false)
      };
    }
  },
  methods: {
    confirmBatch() {
      if (
        this.$refs.crud.tableSelect.length < 1 ||
        this.$refs.crud.tableSelect.length > 10
      ) {
        this.$message.error("选中表数量不合法，数量最少1个或最多为10个");
        return false;
      }
      let ids = [];
      for (const table of this.$refs.crud.tableSelect) {
        ids.push(table);
      }
      confirm(ids)
        .then(data => {
          if (data.code == "0") {
            this.$message.success("确认成功");
          }
          this.getList(this.page);
        })
        .catch(() => {
          //loading();
        });
    }
  }
};
</script>
